<template>
    <sky-base-popup title="快递信息" ref="skyBasePopupRef">
        <view class="form-box">
            <uni-forms ref="formRef" :modelValue="formData" :rules="rules">
                <uni-forms-item label="快递名称" name="express">
                    <uni-easyinput type="text" v-model="formData.express" placeholder="请输入快递名称"/>
                </uni-forms-item>
                <uni-forms-item label="快递单号" name="express_no">
                    <uni-easyinput v-model="formData.express_no" placeholder="请输入快递单号"/>
                </uni-forms-item>
            </uni-forms>
        </view>
        <template #footer>
            <up-button type="primary" shape="circle" color="#b07f63" text="确认发货" @tap="qly.form.pass(confirm,formRef)"></up-button>
        </template>
    </sky-base-popup>
</template>
<script setup>

const skyBasePopupRef = ref()
const formRef = ref()
const formData = ref({
    express: '',
    express_no: '',
})
const rules = {
    express: {
        rules: [
            {
                required: true,
                errorMessage: '请输入快递名称',
            },
        ],
    },
    express_no: {
        rules: [
            {
                required: true,
                errorMessage: '请输入快递单号',
            },
        ],
    }
}

const resolve=ref()

const close = () => {
    skyBasePopupRef.value.close()
}
const open = () => {
    return new Promise((_resolve, reject) => {
        skyBasePopupRef.value.open()
        resolve.value = _resolve
    })

}

// 下单
const confirm = async () => {
    resolve.value({
        confirm: true,
        data:formData.value
    })
    close()
}
defineExpose({
    open
})
</script>
<style scoped lang="scss">
.form-box{
    padding: 32rpx;
    box-sizing: border-box;
}
</style>
